package edu.friday.common.result;

import edu.friday.common.constant.HttpStatus;
import lombok.Data;
import java.io.Serializable;
import java.util.List;

@Data
public class TableDataInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    private long total;
    private List<?> rows;

    private int code;
    private int msg;
    public TableDataInfo(){}
    public TableDataInfo(List<?> list,long total){
        this.total=total;
        this.rows=list;
    }

    /**
     * @param list
     * @param total
     * @return 成功得返回方法
     */
    public static TableDataInfo success(List<?> list,long total){
        TableDataInfo tableDataInfo = new TableDataInfo(list, total);
        tableDataInfo.setCode(HttpStatus.SUCCESS);
        return tableDataInfo;
    }

    public static TableDataInfo error(int msg){
        TableDataInfo tableDataInfo = new TableDataInfo();
        tableDataInfo.setCode(HttpStatus.ERROR);
        tableDataInfo.setMsg(msg);
        return tableDataInfo;
    }
}
